package com.gzist.springailab02.controller;

import com.gzist.springailab02.tools.SystemTimeTool;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 测试接口类
 */
@RestController
@RequiredArgsConstructor
public class UserController {

    private final ChatModel chatModel;
    private final SystemTimeTool systemTimeTool;
    @GetMapping("/test")
    public String test(@RequestParam("userInput") String userInput) {
        ChatClient chatClient = ChatClient.builder(chatModel).build();
        return chatClient.prompt()
                .user(userInput)
                .tools(systemTimeTool)
                .call()
                .content();
    }
}
